package com.sxs.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sxs.service.MenuServiceInterface;

import utils.ReturnMsg;

@Controller
@RequestMapping("menu")
public class MenuController {
	private MenuServiceInterface mService;
	
	@Autowired
	public void setmService(MenuServiceInterface mService) {
		this.mService = mService;
	}

	@RequestMapping("fatherCreate")
	@ResponseBody
	public Object createfatherMenu(HttpSession session) {
		return ReturnMsg.getReturnMsg(mService.createFatherMenu()).buildSuccess();
	}
	
	@RequestMapping("create")
	@ResponseBody
	public Object createMenu(HttpSession session) {
		return ReturnMsg.getReturnMsg(mService.createMenu()).buildSuccess();
	}

	@RequestMapping("createChild")
	@ResponseBody
	public Object createMenuChild(HttpServletRequest request, HttpSession session) {
		String parentMenuCode = request.getParameter("parentMenuCode");
		return ReturnMsg.getReturnMsg(mService.createMenuChild(parentMenuCode, "")).buildSuccess();
	}
}
